code {
  background-color: var(--code-bg, #eee);
  padding: 2px 6px;
  font-size: 0.9em;
  color: var(--link-color, #800);
  border-radius: 4px;
  font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
  transition: background-color 0.3s ease, color 0.3s ease;
}

pre code {
  background-color: transparent;
  padding: 0;
  font-size: 1em;
  color: var(--code-text, #222);
}

pre {
  display: block;
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--code-text, #333);
  word-break: break-word;
  overflow-wrap: break-word;
  overflow-x: auto;
  background-color: var(--code-bg, #f5f5f5);
  border: 1px solid var(--border-color, #ccc);
  border-radius: 6px;
  font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
  box-shadow: 0 1px 3px var(--shadow, rgba(0, 0, 0, 0.1));
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* Enable absolute positioning for copy button and improve hover effect */
pre {
  position: relative;
}

pre:hover {
  box-shadow: 0 2px 6px var(--shadow, rgba(0, 0, 0, 0.15));
}

/*

github.com style (c) Vasily Polovnyov <vast@whiteants.net>

*/

.hljs {
  display: block;
  overflow-x: auto;
  padding: 0.5em;
  color: var(--code-text, #333);
  background: var(--code-bg, #f8f8f8);
  -webkit-text-size-adjust: none;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.hljs-comment,
.diff .hljs-header,
.hljs-javadoc {
  color: #998;
  font-style: italic;
}

.hljs-keyword,
.css .rule .hljs-keyword,
.hljs-winutils,
.nginx .hljs-title,
.hljs-subst,
.hljs-request,
.hljs-status {
  color: #333;
  font-weight: bold;
}

.hljs-number,
.hljs-hexcolor,
.ruby .hljs-constant {
  color: #008080;
}

.hljs-string,
.hljs-tag .hljs-value,
.hljs-phpdoc,
.hljs-dartdoc,
.tex .hljs-formula {
  color: #d14;
}

.hljs-title,
.hljs-id,
.scss .hljs-preprocessor {
  color: #900;
  font-weight: bold;
}

.hljs-list .hljs-keyword,
.hljs-subst {
  font-weight: normal;
}

.hljs-class .hljs-title,
.hljs-type,
.vhdl .hljs-literal,
.tex .hljs-command {
  color: #458;
  font-weight: bold;
}

.hljs-tag,
.hljs-tag .hljs-title,
.hljs-rules .hljs-property,
.django .hljs-tag .hljs-keyword {
  color: #000080;
  font-weight: normal;
}

.hljs-attribute,
.hljs-variable,
.lisp .hljs-body {
  color: #008080;
}

.hljs-regexp {
  color: #009926;
}

.hljs-symbol,
.ruby .hljs-symbol .hljs-string,
.lisp .hljs-keyword,
.clojure .hljs-keyword,
.scheme .hljs-keyword,
.tex .hljs-special,
.hljs-prompt {
  color: #990073;
}

.hljs-built_in {
  color: #0086b3;
}

.hljs-preprocessor,
.hljs-pragma,
.hljs-pi,
.hljs-doctype,
.hljs-shebang,
.hljs-cdata {
  color: #999;
  font-weight: bold;
}

.hljs-deletion {
  background: #fdd;
}

.hljs-addition {
  background: #dfd;
}

.diff .hljs-change {
  background: #0086b3;
}

.hljs-chunk {
  color: #aaa;
}

/* Dark mode support for syntax highlighting */
.code-theme-dark code {
  background-color: var(--code-bg, #2d2d2d);
  color: var(--link-color, #4a9eff);
}

.code-theme-dark pre {
  background-color: var(--code-bg, #2d2d2d);
  border-color: var(--border-color, #444);
  color: var(--code-text, #e0e0e0);
}

.code-theme-dark .hljs {
  background: var(--code-bg, #2d2d2d);
  color: var(--code-text, #e0e0e0);
}

.code-theme-dark .hljs-comment,
.code-theme-dark .diff .hljs-header,
.code-theme-dark .hljs-javadoc {
  color: #6a9955;
}

.code-theme-dark .hljs-keyword,
.code-theme-dark .css .rule .hljs-keyword,
.code-theme-dark .hljs-winutils,
.code-theme-dark .nginx .hljs-title,
.code-theme-dark .hljs-subst,
.code-theme-dark .hljs-request,
.code-theme-dark .hljs-status {
  color: #569cd6;
  font-weight: bold;
}

.code-theme-dark .hljs-number,
.code-theme-dark .hljs-hexcolor,
.code-theme-dark .ruby .hljs-constant {
  color: #b5cea8;
}

.code-theme-dark .hljs-string,
.code-theme-dark .hljs-tag .hljs-value,
.code-theme-dark .hljs-phpdoc,
.code-theme-dark .hljs-dartdoc,
.code-theme-dark .tex .hljs-formula {
  color: #ce9178;
}

.code-theme-dark .hljs-title,
.code-theme-dark .hljs-id,
.code-theme-dark .scss .hljs-preprocessor {
  color: #d7ba7d;
  font-weight: bold;
}

.code-theme-dark .hljs-class .hljs-title,
.code-theme-dark .hljs-type,
.code-theme-dark .vhdl .hljs-literal,
.code-theme-dark .tex .hljs-command {
  color: #4ec9b0;
  font-weight: bold;
}

.code-theme-dark .hljs-tag,
.code-theme-dark .hljs-tag .hljs-title,
.code-theme-dark .hljs-rules .hljs-property,
.code-theme-dark .django .hljs-tag .hljs-keyword {
  color: #569cd6;
  font-weight: normal;
}

.code-theme-dark .hljs-attribute,
.code-theme-dark .hljs-variable,
.code-theme-dark .lisp .hljs-body {
  color: #9cdcfe;
}

.code-theme-dark .hljs-regexp {
  color: #d16969;
}

.code-theme-dark .hljs-symbol,
.code-theme-dark .ruby .hljs-symbol .hljs-string,
.code-theme-dark .lisp .hljs-keyword,
.code-theme-dark .clojure .hljs-keyword,
.code-theme-dark .scheme .hljs-keyword,
.code-theme-dark .tex .hljs-special,
.code-theme-dark .hljs-prompt {
  color: #c586c0;
}

.code-theme-dark .hljs-built_in {
  color: #4fc1ff;
}

.code-theme-dark .hljs-preprocessor,
.code-theme-dark .hljs-pragma,
.code-theme-dark .hljs-pi,
.code-theme-dark .hljs-doctype,
.code-theme-dark .hljs-shebang,
.code-theme-dark .hljs-cdata {
  color: #808080;
  font-weight: bold;
}

.code-theme-dark .hljs-deletion {
  background: #5a1d1d;
  color: #f48771;
}

.code-theme-dark .hljs-addition {
  background: #1e3a1e;
  color: #b5cea8;
}

.code-theme-dark .diff .hljs-change {
  background: #2d4d2d;
  color: #4ec9b0;
}

.code-theme-dark .hljs-chunk {
  color: #808080;
}

/* Accessibility: Ensure sufficient contrast for code */
code,
pre,
.hljs {
  /* WCAG AA compliant contrast ratios */
  min-height: 1.5em;
}

/* Improve code block readability on small screens */
@media (max-width: 768px) {
  pre {
    font-size: 12px;
    padding: 10px;
    margin: 12px 0;
  }

  code {
    font-size: 0.85em;
    padding: 2px 4px;
  }
}

/* Print styles for code blocks */
@media print {
  pre {
    border: 1px solid #ccc;
    page-break-inside: avoid;
    background: #f5f5f5;
    color: #000;
  }

  code {
    background: #f0f0f0;
    color: #000;
  }
}
